package rate

import (
	"errors"
	"strings"
)

var globalCurrencyMap *CurrencyMap

func InitRate(token string) error {
	token = strings.TrimSpace(token)
	if strings.EqualFold(token, "") {
		return errors.New("rate path can not be empty")
	}
	globalCurrencyMap = NewCurrencyMap(token)
	return nil
}

func SyncCurrencyRate() map[string]float64 {
	return globalCurrencyMap.Sync()
}
